﻿@using System.Data;
@using Shop.Entity;
@using Shop.Help;
@using Shop.Bll;
@using Webdiyer.WebControls.Mvc
@using System.Web.Mvc.Ajax;
@model  PagedList<DataRow>

@{
    Layout = null;
    string actionString = RoleLogic.GetPowerStr("MyBusiness", ManagerLogic.GetLoginInfo().ManagerRoleGuid);
}
<script src="/Content/LwsJS/List.js"></script>
<table class="table table-bordered  table-condensed table-condensed  table-hover table-condensed">
    <thead>
        <tr>
            <th></th>
            <th>商户</th>
            <th>所属行业</th>
            <th>门店数量</th>
            <th>法人</th>
            <th>联系方式</th>
            <th>显示顺序</th>
            <th>入驻时间</th>
            <th>到期时间</th>
            <th class="hidden-xs">操作</th>
        </tr>
    </thead>
    <tbody>
        @foreach (var row in Model)
        {
            <tr>
                <td>
                    <input type="checkbox" name="subBox" value="@row["Guid"]" />
                </td>
                <td class="title">@row["BusinessName"]</td>
                <td>@row["Title"]</td>
                <td>@row["StoreCount"]</td>
                <td>@row["Contact"]</td>
                <td>@row["Tel"]</td>
                <td>@row["Sort"]</td>

                <td>@Convert.ToDateTime(row["RegisterTime"]).ToString("yyyy-MM-dd HH:mm")</td>
                <td>@Convert.ToDateTime(row["Duetime"]).ToString("yyyy-MM-dd")</td>
                <td>
                    @if (actionString.Contains("Edit"))
                    {
                        <a class="btn btn-default btn-xs" title='编辑信息' href="/business/business/add/@row["Guid"]">编辑</a>
                    }
                    @if (actionString.Contains("Delete"))
                    {
                        <a class="btn btn-default btn-xs" title='类别下已有资讯不可删除' onclick="Delete('@row["Guid"]');">删除 </a>
                    }
                </td>
            </tr>
        }
    </tbody>
</table>
<input type="hidden" value="@Model.CurrentPageIndex" id="PageIndex" />
<div class="text-left">
    <ul class="pagination">
        <li>
            <span aria-hidden="true">
                @(Model.PageSize)条/页，@(Model.TotalPageCount)页, 共@(Model.TotalItemCount)条
            </span>
        </li>

        <li>
            <span aria-hidden="true">
                每页
                <select style="border-radius:4px;font-family:normal;vertical-align: text-bottom;" id="PageSize" name="PageSize" onchange="PageSizeChange();">
                    <option value="10">10</option>
                    <option value="15">15</option>
                    <option value="20">20</option>
                </select>
                条
            </span>
        </li>
    </ul>
    @Ajax.Pager(Model,
new PagerOptions
{
    PageIndexParameterName = "id",
    CssClass = "pagination",
    FirstPageText = "首页",
    LastPageText = "尾页",
    PrevPageText = "上一页",
    PageIndexBoxId = "pageIndexBox",
    NextPageText = "下一页",
    CurrentPagerItemTemplate = "<li class=\"active\"><a data-pageindex=\"{0}\" href=\"/articleinfo/articlecategory/list/{0}\">{0}</a></li>",
    DisabledPagerItemTemplate = "<li class=\"disabled\"><a>{0}</a></li>",
    PagerItemTemplate = "<li>{0}</li>",
    AutoHide = false,

}, new MvcAjaxOptions
{
    UpdateTargetId = "divTable",
    HttpMethod = "Get",
    DataFormId = "formSearch",
    EnableHistorySupport = false,
    OnSuccess = "Success()",
}
)
    <ul class="pagination" style="width:20%;margin-top: 0px;">
        <li>
            <div class="input-group">
                <span class="input-group-addon" id="sizing-addon2">第</span>
                <input type="text" id="pageIndexBox" class="form-control input-sm" placeholder="" aria-describedby="sizing-addon2">
                <span class="input-group-addon">页</span>
                <span class="input-group-btn">
                    <button class="btn btn-primary btn-sm" type="button">Go</button>
                </span>
            </div>
        </li>
    </ul>
</div>
<script type="text/javascript">


    function Success()
    {
        $("input[name='PageSize']").val('@ViewData["NowPageSize"]');
        $("#PageSize").val(@ViewData["NowPageSize"]);

        var txt = $("input[name='BusinessName']").val();
        if (txt.length > 0)
        {
            $(".title").each(function ()
            {
                var newTxt = $(this).html().replace(txt, txt.fontcolor("red"));
                $(this).html(newTxt);
            });
        }
    }
</script>
